package com.example.review_generator

import Generator
import android.os.Bundle
import android.text.method.ScrollingMovementMethod
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.show_fragment.*

class article_show:Fragment() {


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

        return inflater.inflate(R.layout.show_fragment,container,false)

    }

    override fun onStart() {


        init_article()
        super.onStart()
    }

    fun init_article(){

        //调用主活动
        var ma:MainActivity= activity as MainActivity

        //输出文章内容
        //直接调用主活动的参数
        var my_generator=Generator(ma.name,ma.place,ma.thing,
            ma.to_who,ma.type,ma.num)
        my_generator.start()
        my_generator.body()
        my_generator.end()
        article.text = my_generator.article

        //设置垂直滚动
        article.movementMethod = ScrollingMovementMethod.getInstance()

    }


}